<?php
/**
 * author      :chenwenwen
 * createTime  :2020-04-12 17:16
 * description :记录和数字相关的类库中的方法
 */

declare(strict_types=1);
namespace app\common\lib;
class Num {


    /**
     * 生成4-6位验证码
     * @param int $length
     * @return int
     */
    public static function getCode(int $length = 4): int {
        $code = rand(1000, 9999);
        if (6 == $length) $code = rand(100000, 999999);

        return $code;
    }
}